def user = session.appUser();
def todayDate = new Date().format('yyyy-MM-dd');

def id = db.find("select ID from DIARY where OPEN_ID=? and DATE=?",user.openId,todayDate);
log.debug("id:",id);

//更新日记信息
if(!id){
	db.exec("insert into DIARY (OPEN_ID,DATE) values (?,?)"
			,user.openId
			,now
			);
}
id = db.find("select ID from DIARY where OPEN_ID=? and DATE=?",user.openId,todayDate);

return id;